from datetime import timedelta

# -*- coding: utf-8 -*-
from datetime import timedelta

from jms.ods.tab.tab_order_source_group import jms_ods__tab_order_source_group
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator


jms_dim__dim_tab_order_source_group = SparkSqlOperator(
    task_id='jms_dim__dim_tab_order_source_group',
    email=['payne.jiang@jtexpress.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='jms_dim__dim_tab_order_source_group_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dim/tab/dim_tab_order_source_group/execute.hql',
    pool_slots=2,
    executor_cores=2,
    executor_memory='3G',
    num_executors=2,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          #'spark.dynamicAllocation.maxExecutors'             : 32,
          'spark.dynamicAllocation.maxExecutors'             : 5,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '1G',
          },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=60),
    retries=2,
    sla=timedelta(minutes=50),)

jms_dim__dim_tab_order_source_group << jms_ods__tab_order_source_group
